# Copyright (c) 2023-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

cmake_minimum_required(VERSION 3.18)

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
    cmake_policy(SET CMP0135 NEW)
endif()

set(MKL_3rdparty_DIR "${CMAKE_SOURCE_DIR}/3rdparty/mkl")

if(NOT EXISTS ${MKL_3rdparty_DIR})
    find_package(Python COMPONENTS Interpreter Development)
    execute_process(COMMAND ${Python_EXECUTABLE} -m pip install --force-reinstall
                            --prefix=${MKL_3rdparty_DIR} mkl-static==2024.0.0 mkl-include==2024.0.0
                    RESULT_VARIABLE EXIT_CODE)

    if(NOT ${EXIT_CODE} EQUAL 0)
        message(STATUS "Dependency MKL installation failed. Please check the logs for more info.")
    endif()
else()
    message(STATUS "MKL directory already exists. Skipping installation.")
endif()
